/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  

  checkConfig(config);
  @endpoint = getEndpoint('cloudauth-console', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model RetrieveFaceRequest {
  projectId?: string(name='ProjectId'),
  face64String?: string(name='Face64String'),
  faceUrl?: string(name='FaceUrl'),
}

model RetrieveFaceResponseBody = {
  requestId?: string(name='RequestId'),
  data?: {
    data?: [ 
    {
      userId?: long(name='UserId'),
      userName?: string(name='UserName'),
      rate?: string(name='Rate'),
    }
  ](name='Data')
  }(name='Data'),
  success?: boolean(name='Success'),
}

model RetrieveFaceResponse = {
  headers: map[string]string(name='headers'),
  body: RetrieveFaceResponseBody(name='body'),
}

async function retrieveFaceWithOptions(request: RetrieveFaceRequest, runtime: Util.RuntimeOptions): RetrieveFaceResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('RetrieveFace', '2019-04-03', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function retrieveFace(request: RetrieveFaceRequest): RetrieveFaceResponse {
  var runtime = new Util.RuntimeOptions{};
  return retrieveFaceWithOptions(request, runtime);
}

model UploadIdentifyRecordRequest {
  userId?: string(name='UserId'),
  userName?: string(name='UserName'),
  projectId?: string(name='ProjectId'),
  iotId?: string(name='IotId'),
  identifyingImageBase64?: string(name='IdentifyingImageBase64'),
  identifyingTime?: long(name='IdentifyingTime'),
  identifyingImageUrl?: string(name='IdentifyingImageUrl'),
  deviceName?: string(name='DeviceName'),
  productKey?: string(name='ProductKey'),
  deviceSecret?: string(name='DeviceSecret'),
  ext?: string(name='Ext'),
}

model UploadIdentifyRecordResponseBody = {
  requestId?: string(name='RequestId'),
  httpStatusCode?: int32(name='HttpStatusCode'),
  success?: boolean(name='Success'),
}

model UploadIdentifyRecordResponse = {
  headers: map[string]string(name='headers'),
  body: UploadIdentifyRecordResponseBody(name='body'),
}

async function uploadIdentifyRecordWithOptions(request: UploadIdentifyRecordRequest, runtime: Util.RuntimeOptions): UploadIdentifyRecordResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('UploadIdentifyRecord', '2019-04-03', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function uploadIdentifyRecord(request: UploadIdentifyRecordRequest): UploadIdentifyRecordResponse {
  var runtime = new Util.RuntimeOptions{};
  return uploadIdentifyRecordWithOptions(request, runtime);
}

